package com.mroapp.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.mroapp.R;
import com.mroapp.activity.AlbumActivity;
import com.mroapp.activity.MenuActivity;
import com.mroapp.activity.MontiorActivity;
import com.mroapp.activity.MusicActivity;
import com.mroapp.activity.StoryActivity;
import com.mroapp.activity.VideoActivity;
import com.mroapp.widget.WinImageView;

public class EntertainmentFragment extends Fragment implements WinImageView.ClickListener{
    private TextView title_name;
    private com.mroapp.widget.WinImageView btn_music;
    private com.mroapp.widget.WinImageView btn_story;
    private com.mroapp.widget.WinImageView btn_menu;
    private com.mroapp.widget.WinImageView btn_album;
    private com.mroapp.widget.WinImageView btn_weather;
    private com.mroapp.widget.WinImageView btn_video;
    private boolean isLogined=false;
    private boolean isBinded=false;

    /**
     * 做个判断  如果没有登录 显示nologin界面
     * 登录之后  如果没有绑定设备 显示binddevice界面
     * 处于登录状态  并且绑定了设备 显示多媒体界面
     * @param inflater
     * @param container
     * @param savedInstanceState
     * @return
     */

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
	{
        View view=null;
//        if(!isLogined){
//            view=inflater.inflate(R.layout.nologin,container,false);
//        }else if(isLogined && !isBinded){
//            view=inflater.inflate(R.layout.devicebind,container,false);
//        }else if(isLogined && isBinded){
//            view=inflater.inflate(R.layout.entertainment,container,false);
//        }
        view=inflater.inflate(R.layout.entertainment,container,false);
        initView(view);
        return view;
	}


    public void initView(View view){
        title_name=(TextView)view.findViewById(R.id.title_name);
        title_name.setText("多媒体");
        btn_music=(WinImageView)view.findViewById(R.id.btn_music);
        btn_music.setClickListener(this);
        btn_story=(WinImageView)view.findViewById(R.id.btn_story);
        btn_story.setClickListener(this);
        btn_menu=(WinImageView)view.findViewById(R.id.btn_menu);
        btn_menu.setClickListener(this);
        btn_album=(WinImageView)view.findViewById(R.id.btn_album);
        btn_album.setClickListener(this);
        btn_weather=(WinImageView)view.findViewById(R.id.btn_weather);
        btn_weather.setClickListener(this);
        btn_video=(WinImageView)view.findViewById(R.id.btn_user_video);
        btn_video.setClickListener(this);
    }

    @Override
        public void onClick(View v) {
            switch (v.getId()){
                case R.id.btn_music:
                    Intent music=new Intent(EntertainmentFragment.this.getActivity(), MusicActivity.class);
                    startActivity(music);
                    break;
                case R.id.btn_story:
                    Intent story=new Intent(EntertainmentFragment.this.getActivity(), StoryActivity.class);
                    startActivity(story);
                    break;
                case R.id.btn_menu:
                    Intent menu=new Intent(EntertainmentFragment.this.getActivity(), MenuActivity.class);
                    startActivity(menu);
                    break;
                case R.id.btn_album:
                    Intent album=new Intent(EntertainmentFragment.this.getActivity(), AlbumActivity.class);
                    startActivity(album);
                    break;
                case R.id.btn_weather:
                    Intent weather=new Intent(EntertainmentFragment.this.getActivity(), MontiorActivity.class);
                    startActivity(weather);
                    break;
                case R.id.btn_user_video:
                    Intent video=new Intent(EntertainmentFragment.this.getActivity(), VideoActivity.class);
                    startActivity(video);
                    break;

            }
    }
}
